home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / eflibpt4.zip / DEMO / MISC / MEMDUP.PAS < prev    next >
Pascal/Delphi Source File  |  1996-08-02  |  967b  |  28 lines

  1. { Borland Pascal Extended Function Library - EFLIB (C) Johan Larsson, 1996
  2.   Demonstration; duplication of memory allocations
  3.  
  4.   EFLIB IS PROTECTED BY THE COPYRIGHT LAW AND MAY NOT BE COPIED, SOLD OR
  5.   MANIPULATED. FOR MORE INFORMATION, SEE PROGRAM MANUAL! THIS DEMONSTRAT-
  6.   ION PROGRAM MAY FREELY BE USED AND DISTRIBUTED.                          }
  7.  
  8.  
  9. uses EFLIBMEM;
  10.  
  11.  
  12. var Data1, Data2: AllocationObjectPointerType;
  13.     SomeData : string;
  14.  
  15. begin
  16.      SomeData := 'Duplication of memory allocation succeeded.';
  17.  
  18.      { Initialize a data allocation and move in some data }
  19.      New (Data1, Initialize (SizeOf(SomeData)));
  20.      Data1^.MoveIn (@SomeData[0], SizeOf(SomeData), 0);
  21.  
  22.      { Duplicate allocated data into a new data allocation object }
  23.      New (Data2, InitializeDuplicate (Data1));
  24.      Data1^.Free; { Dispose first allocation }
  25.  
  26.      WriteLn (String(Data2^.DataPointer(0)^));
  27.      Data2^.Free; { Dispose second allocation }
  28. end.